package com.cari.oa.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.cari.oa.dao.BaseDao;
import com.cari.oa.dao.MarketCostDao;
import com.cari.oa.domain.MarketCostEntity;

@Service
@Transactional(rollbackFor = Exception.class)
public class MarketCostService extends BaseService<MarketCostEntity> {
	
	@Resource
	private MarketCostDao marketCostDao;

	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public BaseDao<MarketCostEntity> getDao() {
		return marketCostDao;
	}

	@Transactional(readOnly=true)
	public List<MarketCostEntity> getPage(String applyUser, String selectProvince, Integer status, 
			Integer sort, Set<String> userProvinces, int page, int size){
		return marketCostDao.getPage(applyUser, selectProvince, status, sort, userProvinces, page, size);
	}
	@Transactional(readOnly=true)
	public long getCount(String applyUser, String selectProvince, Integer status, 
			Integer sort, Set<String> userProvinces){
		return marketCostDao.getCount(applyUser, selectProvince, status, sort, userProvinces);
	}
	
	@Transactional(readOnly=true)
	public List<MarketCostEntity> getUserPage(String applyUser, String selectProvince, Integer status, 
			Integer sort, Set<String> userProvinces, int page, int size){
		return marketCostDao.getUserPage(applyUser, selectProvince, status, sort, userProvinces, page, size);
	}
	@Transactional(readOnly=true)
	public long getUserCount(String applyUser, String selectProvince, Integer status, 
			Integer sort, Set<String> userProvinces){
		return marketCostDao.getUserCount(applyUser, selectProvince, status, sort, userProvinces);
	}
	
	@SuppressWarnings("rawtypes")
	@Transactional(readOnly=true)
	public List<Map>  getTotalCost(Integer year, Integer month, Integer page, Integer size){
		return marketCostDao.getTotalCost(year, month, page, size);
	}
	
	@Transactional(readOnly=true)
	public long getTotalCostCount(Integer year, Integer month){
		return marketCostDao.getTotalCostCount(year, month);
	}
	
	@SuppressWarnings("rawtypes")
	@Transactional(readOnly=true)
	public List<Map> getTotalCostByProvince(String province, Integer year){
		return marketCostDao.getTotalCostByProvince(province, year);
	}
	
	@Transactional(readOnly=true)
	public List<Integer> getAllRecordsYear(){
		return marketCostDao.getAllRecordsYear();
	}
}
